
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>环境变量 · classbro-u-center-web-v2.0</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="Gj">
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-chapter-fold/chapter-fold.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search-pro/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-prism/prism-tomorrow.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
        <link rel="stylesheet" href="../index.css">
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="I18n.html" />
    
    
    <link rel="prev" href="Utils.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    概要
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="Utils.html">
            
                <a href="Utils.html">
            
                    
                    工具集
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.3" data-path="Config.html">
            
                <a href="Config.html">
            
                    
                    环境变量
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="I18n.html">
            
                <a href="I18n.html">
            
                    
                    国际化
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="Interceptor.html">
            
                <a href="Interceptor.html">
            
                    
                    拦截器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="Vuex.html">
            
                <a href="Vuex.html">
            
                    
                    Vuex
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="Api.html">
            
                <a href="Api.html">
            
                    
                    接口文件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="Icon.html">
            
                <a href="Icon.html">
            
                    
                    图标
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="Xss.html">
            
                <a href="Xss.html">
            
                    
                    Xss
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="Permission.html">
            
                <a href="Permission.html">
            
                    
                    菜单&权限校验
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >环境变量</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="&#x73AF;&#x5883;&#x53D8;&#x91CF;">&#x73AF;&#x5883;&#x53D8;&#x91CF;</h1>
<blockquote>
<p>&#x811A;&#x672C;&#x542F;&#x52A8;&#x65F6;&#xFF0C;&#x52A0;&#x8F7D;&#x5230;<code>node</code>&#x8FDB;&#x7A0B;&#x4E2D;</p>
<p>&#x6B64;&#x6587;&#x4EF6;&#x4E00;&#x822C;&#x4E0D;&#x505A;&#x4FEE;&#x6539;</p>
</blockquote>
<h4 id="&#x542F;&#x52A8;&#x6253;&#x5305;">&#x542F;&#x52A8;/&#x6253;&#x5305;</h4>
<blockquote>
<p>&#x4EE5; <code>yarn</code> &#x4E3A;&#x4F8B;</p>
<p>yarn dev == npm run dev</p>
<p><span style="color: #F56C6C">&#x6CE8;&#xFF1A;&#x672C;&#x5730;&#x542F;&#x52A8; prod &#x4EC5;&#x4E3A; &#x7EBF;&#x4E0A;&#x73AF;&#x5883;&#x51FA;&#x73B0;&#x95EE;&#x9898;&#xFF0C;&#x672C;&#x5730;&#x8C03;&#x8BD5;&#x4F5C;&#x7528;</span></p>
</blockquote>
<pre class="language-"><code class="lang-bash"><span class="token function">yarn</span> dev          <span class="token comment"># &#x672C;&#x5730;&#x5F00;&#x53D1;&#x73AF;&#x5883;</span>
<span class="token function">yarn</span> dev:test      <span class="token comment"># &#x6D4B;&#x8BD5;&#x73AF;&#x5883; &#x672C;&#x5730;&#x8C03;&#x8BD5;</span>
<span class="token function">yarn</span> dev:preview <span class="token comment"># &#x9884;&#x53D1;&#x73AF;&#x5883; &#x672C;&#x5730;&#x8C03;&#x8BD5;</span>
<span class="token function">yarn</span> prod          <span class="token comment"># &#x751F;&#x4EA7;&#x73AF;&#x5883; &#x672C;&#x5730;&#x8C03;&#x8BD5; &#x5C3D;&#x91CF;&#x4E0D;&#x8981;&#x7528;&#x8FD9;&#x4E2A;&#x547D;&#x4EE4;&#x542F;&#x52A8;</span>
</code></pre>
<blockquote>
<p>&#x6253;&#x5305;</p>
</blockquote>
<pre class="language-"><code class="lang-bash"><span class="token function">yarn</span> build:test <span class="token comment"># &#x6D4B;&#x8BD5;&#x73AF;&#x5883; &#x6253;&#x5305;</span>
<span class="token function">yarn</span> build        <span class="token comment"># &#x751F;&#x4EA7;&#x73AF;&#x5883; &#x6253;&#x5305;</span>
</code></pre>
<h4 id="&#x53D8;&#x91CF;&#x4F7F;&#x7528;">&#x53D8;&#x91CF;&#x4F7F;&#x7528;</h4>
<blockquote>
<p>&#x76F4;&#x63A5;&#x8BF7;&#x6C42;config&#x52A0;&#x8F7D;&#x73AF;&#x5883;&#x53D8;&#x91CF;</p>
</blockquote>
<pre class="language-"><code class="lang-javascript"><span class="token keyword">import</span> <span class="token punctuation">{</span> <span class="token constant">OSS_URL</span><span class="token punctuation">,</span> RequestTimeout<span class="token punctuation">,</span> CookieExpires<span class="token punctuation">,</span> Prefix<span class="token punctuation">,</span> <span class="token operator">...</span> <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">&quot;config&quot;</span><span class="token punctuation">;</span>
</code></pre>
<h4 id="env">.env</h4>
<blockquote>
<p>&#x8FD9;&#x4E2A;&#x6587;&#x4EF6;&#x662F;&#x6240;&#x6709;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x662F;&#x5168;&#x5C40;&#x9ED8;&#x8BA4;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#xFF0C;&#x4E0D;&#x8BBA;&#x4EC0;&#x4E48;&#x73AF;&#x5883;&#x90FD;&#x4F1A;&#x52A0;&#x8F7D;&#x5408;&#x5E76;&#x3002;&#x9664;&#x975E;&#x662F;<strong>&#x6240;&#x6709;&#x73AF;&#x5883;</strong>&#x90FD;&#x9700;&#x8981;&#x4F7F;&#x7528;&#x7684;&#x65F6;&#x5019;&#x4E14;&#x4E0D;&#x9700;&#x8981;&#x6539;&#x53D8;&#x3002;&#x5C3D;&#x91CF;&#x4E0D;&#x8981;&#x4FEE;&#x6539;&#x5B83;&#x3002;</p>
<p>&#x5982;&#x679C;&#x662F;&#x5355;&#x72EC;&#x79C1;&#x6709;&#x7684;&#x53D8;&#x91CF;&#x4E14;&#x5176;&#x4ED6;&#x73AF;&#x5883;&#x4E0D;&#x540C;&#x65F6;&#xFF0C;&#x4F8B;&#x5982;&#x4EE3;&#x7406;&#x67D0;&#x67D0;&#x540C;&#x4E8B;&#x672C;&#x5730;&#x7684;&#x7F51;&#x5173;&#xFF0C;&#x8FD9;&#x4E00;&#x7C7B;&#x53EA;&#x9700;&#x8981;&#x5728;&#x81EA;&#x5DF1;&#x7684;<strong>.env.development</strong>&#x91CC;&#x9762;&#x6539;&#x5199;&#x5C31;&#x53EF;&#x4EE5;&#x4E86;&#x3002;</p>
</blockquote>
<h4 id="&#x521D;&#x59CB;&#x5316;&#x672C;&#x5730;&#x914D;&#x7F6E;&#x6587;&#x4EF6;">&#x521D;&#x59CB;&#x5316;&#x672C;&#x5730;&#x914D;&#x7F6E;&#x6587;&#x4EF6;</h4>
<blockquote>
<p>&#x9879;&#x76EE;&#x5982;&#x679C;&#x65F6;&#x7B2C;&#x4E00;&#x6B21;&#x542F;&#x52A8;<strong>npm run dev</strong>&#xFF0C;&#x9ED8;&#x8BA4;&#x672C;&#x5730;&#x662F;&#x6CA1;&#x6709;&#x914D;&#x7F6E;&#x6587;&#x4EF6;<strong>.env.development</strong>&#x7684;&#x3002;</p>
<p>&#x9996;&#x6B21;&#x9700;&#x8981;&#x672C;&#x5730;&#x8FD0;&#x884C; <strong>npm run cfg</strong> &#x6216;&#x8005; <strong>yarn cfg</strong>&#x521D;&#x59CB;&#x5316;&#x672C;&#x5730;&#x542F;&#x52A8;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x3002;</p>
<p><strong>*nux</strong>&#x73AF;&#x5883;&#x5982;&#x679C;&#x8981;&#x751F;&#x6210;<strong>.env.development</strong> &#x53EF;&#x4EE5;&#x76F4;&#x63A5; <strong>./script/generateConfig.sh</strong></p>
<p>&#x6B64;&#x6587;&#x4EF6;&#x5DF2;&#x52A0;&#x5165;<strong>.gitignore</strong>&#xFF0C;&#x6240;&#x4EE5;&#x4E0D;&#x4F1A;&#x88AB;<strong>git</strong>&#x63D0;&#x4EA4;&#x5230;&#x4ED3;&#x5E93;&#x91CC;&#x9762;&#x3002;</p>
<p>&#x5177;&#x4F53;&#x53D8;&#x91CF;&#x58F0;&#x660E;&#x65B9;&#x5F0F;&#xFF0C;&#x518D;&#x672C;&#x5730;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x91CC;&#x9762;&#x6709;&#x6807;&#x6CE8;&#x3002;</p>
</blockquote>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="Utils.html" class="navigation navigation-prev " aria-label="Previous page: 工具集">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="I18n.html" class="navigation navigation-next " aria-label="Next page: 国际化">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"环境变量","level":"1.3","depth":1,"next":{"title":"国际化","level":"1.4","depth":1,"path":"src/I18n.md","ref":"src/I18n.md","articles":[]},"previous":{"title":"工具集","level":"1.2","depth":1,"path":"src/Utils.md","ref":"src/Utils.md","articles":[]},"dir":"ltr"},"config":{"plugins":["chapter-fold","-lunr","-search","search-pro","-highlight","prism","livereload"],"styles":{"website":"index.css"},"pluginsConfig":{"prism":{"css":["prismjs/themes/prism-tomorrow.css"]},"chapter-fold":{},"search-pro":{},"livereload":{},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"Gj","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"classbro-u-center-web-v2.0","language":"zh-hans","gitbook":"3.2.3","description":"u-center-web 项目迁移 重构"},"file":{"path":"src/Config.md","mtime":"2020-07-27T06:30:54.930Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2020-07-27T06:50:03.177Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-chapter-fold/chapter-fold.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-pro/jquery.mark.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-pro/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

